package sugarbind_input

class Agent_TypeController {

    def scaffold = true
	
//	def ddlagents = {}
	
	def findAgents = { 
		println("params : " +params)
		
		def agent_Type
		def agents
		
		try
		{
			agent_Type = Agent_Type.get(params.agent_Type.id)
		}
		catch(Exception ex)
		{
			println(ex.getMessage())
		}
	
		if(agent_Type != null)
		{
			agents = agent_Type.agents
		}
		else
		{
			agents = Agent.listAgents()
		}
		render(template: 'ddlAgents', model:  [agents : agents])
  }
	
	def findAgent_Types = {
		println("findAgent_Types params : " +params)
			
		def agent_Types = Agent_Type.listAgent_Types()
		def selected


		try
		{
			selected = Agent_Type.get(params.agent_Type.id)
		}
		catch(Exception ex)
		{
			println(ex.getMessage())
		}
		println(agent_Types)
		println(selected)
		
		render(template: 'ddlAgent_Types', model:  [agent_Types : agent_Types, selected:selected])
	  }
		
		
//	  }
}
